<?php
class BeiyongyiModel extends Action{
	
	//公版
	public function getmo($beiyongyiid){
		$info=collectinfo(__METHOD__,'$beiyongyiid',array($beiyongyiid));
		if(isset($beiyongyiid)===false){return createarrerr('error_code','beiyongyiid 不能为空',$info);}//防止NULL
		
		$beiyongyi=M('beiyongyi');
		$beiyongyio=$beiyongyi->where('beiyongyiid='.$beiyongyiid)->find();

		
		return createarrok('ok',$beiyongyio,'',$info);
	}

	// //公版
	// public function getmls(){
	// 	$info=collectinfo(__METHOD__,'',array());
	// 	$beiyongyi=M('beiyongyi');
	// 	$beiyongyils=$beiyongyi->join('tb_bd ON f_beiyongyi_bdid=bdid')->select();
	// 	return createarrok('ok',$beiyongyils,'',$info);
	// }

	// //公版
	// public function getmlsbybdid($bdid){
	// 	$info=collectinfo(__METHOD__,'$bdid',array($bdid));
	// 	if(isset($bdid)===false){return createarrerr('error_code','bdid 不能为空',$info);}//防止NULL

	// 	$beiyongyi=M('beiyongyi');
	// 	$beiyongyils=$beiyongyi->join('tb_bd ON f_beiyongyi_bdid=bdid')->where('f_beiyongyi_bdid='.$bdid)->select();

	// 	return createarrok('ok',$beiyongyils,'',$info);
	// }
	
	// //公版
	// public function deletebybdid($bdid){
	// 	$info=collectinfo(__METHOD__,'$bdid',array($bdid));
	// 	if(isset($bdid)===false){return createarrerr('error_code','bdid 不能为空',$info);}//防止NULL
		
	// 	$arr_beiyongyils=$this->getmlsbybdid($bdid);$beiyongyils=$arr_beiyongyils['data'];
	// 	foreach($beiyongyils as $beiyongyiv){
	// 		$this->delete($beiyongyiv['beiyongyiid']);
	// 	}

	// 	return createarrok('ok',$data,'',$info);
	// }

	// //公版
	// public function delete($beiyongyiid){
	// 	$info=collectinfo(__METHOD__,'$beiyongyiid',array($beiyongyiid));
	// 	if(isset($beiyongyiid)===false){return createarrerr('error_code','beiyongyiid 不能为空',$info);}//防止NULL
		
	// 	$beiyongyi=M('beiyongyi');$bdbeiyongyi=D('Ccbeiyongyi');
	// 	$beiyongyi->where('beiyongyiid='.$beiyongyiid)->delete();
	// 	//删除依赖
 //      	$bdbeiyongyi->deletebybeiyongyiid($beiyongyiid);
      	
	// 	return createarrok('ok',$data,'',$info);
	// }

	//公版
	public function add($get){
		$info=collectinfo(__METHOD__,'$get',array($get));
		if(isset($get)===false){return createarrerr('error_code','get 不能为空',$info);}//防止NULL
		
		$beiyongyi=M('beiyongyi');
		$beiyongyi->data($get)->add();

		return createarrok('ok',$data,'',$info);
	}

	//公版
	public function mdf($get,$id){
		$info=collectinfo(__METHOD__,'$get,$id',array($get,$id));
		if(isset($get)===false){return createarrerr('error_code','get 不能为空',$info);}//防止NULL
		if(isset($id)===false){return createarrerr('error_code','beiyongyiid 不能为空',$info);}//防止NULL

		$beiyongyi=M('beiyongyi');
		$beiyongyi->where('beiyongyiid='.$id)->setField($get);

		return createarrok('ok',$data,'',$info);
	}

	//
	public function addbeiyongyicnt($origincnt,$beiyongyiid){
		$info=collectinfo(__METHOD__,'$origincnt,$beiyongyiid',array($origincnt,$beiyongyiid));
		if(isset($origincnt)===false){return createarrerr('error_code','origincnt 不能为空',$info);}//防止NULL
		if(isset($beiyongyiid)===false){return createarrerr('error_code','beiyongyiid 不能为空',$info);}//防止NULL

		$beiyongyi=M('beiyongyi');
		$nwcnt=$origincnt+1;
		$dt=array('beiyongyicnt'=>$nwcnt);
		$beiyongyi->where('beiyongyiid='.$beiyongyiid)->setField($dt);

		return createarrok('ok',$nwcnt,'',$info);
	}



} 
?>